function log(t){
	try{console.log(t)}catch(e){}
	try{air.Introspector.Console.log(t)}catch(e){}
};
function die(t){
	try{console.warn(t)}catch(e){}return false
	try{air.Introspector.Console.warn(t)}catch(e){}return false
};

String.prototype.ltrim = function(str){ if (str) return this.replace(eval("/^"+str+"+/"),""); else return this.replace(/^\s+/,""); }
String.prototype.rtrim = function(str){ if (str) return this.replace(eval("/"+str+"+$/"),""); else return this.replace(/\s+$/,"") }
String.prototype.trim = function(str){	return this.ltrim(str).rtrim(str) }
String.prototype.clean = function(str){ if (str) return this.replace(eval("/"+str+"+/g"),""); else return this.replace(/\s+/,"") }

Array.prototype.in_array = function(v){for(var i=0,l=this.length;i<l;i++)if(this[i]==v)return i; return false;}
Array.prototype.remove = function(v){var nA=new Array();for(var i=0,l=this.length;i<l;i++) if(this[i]!=v)nA.push(this[i]);return nA;}

Date.prototype.format = function(format){ return formatDate(this,format||'dd/mm/yyyy') }
function LZ(x){return(x<0||x>9?"":"0")+x}
function formatDate(date,format) {
	format=format+"";
	var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	var result="", i_format=0, c="", token="", y=date.getYear()+"", M=date.getMonth()+1, d=date.getDate(), E=date.getDay(), H=date.getHours(), m=date.getMinutes(), s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k, value=new Object();
	if (y.length < 4) y=""+(y-0+1900);
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0)value["h"]=12; else if (H>12)value["h"]=H-12; else value["h"]=H;
	value["hh"]=LZ(value["h"]);
	if (H>11)value["K"]=H-12; else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) value["a"]="PM"; else value["a"]="AM";
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format); token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) token += format.charAt(i_format++);
		if (value[token] != null) result=result + value[token]; else result=result + token;
	}
	return result;
}


/*gears init*/
(function() {
  if (window.google && google.gears) return;
  var factory = null;
  if (typeof GearsFactory != 'undefined') factory = new GearsFactory(); //Firefox
  else {
    try{ // IE
      factory = new ActiveXObject('Gears.Factory');
      if (factory.getBuildInfo().indexOf('ie_mobile') != -1) factory.privateSetGlobalObject(this); 
    } catch (e) {
      // Safari
      if ((typeof navigator.mimeTypes != 'undefined') && navigator.mimeTypes["application/x-googlegears"]) {
        factory = document.createElement("object");
        factory.style.display = "none";
        factory.width = 0;
        factory.height = 0;
        factory.type = "application/x-googlegears";
        document.documentElement.appendChild(factory);
      }
    }
  }
  if (!factory){ return; }
  if (!window.google){ google = {}; }
  if (!google.gears){ google.gears = {factory: factory}; }
})();
